package com.ruoyi.project.records.controller;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.records.domain.DrugSale;
import com.ruoyi.project.records.service.IDrugSaleService;
import com.sun.deploy.net.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/records/drugSale")
public class DrugSaleController extends BaseController {
    @Autowired
    private IDrugSaleService drugSaleService;

    //根据药品名称和时间动态查询药品销售信息
    @RequestMapping("/list")
    @PreAuthorize("@ss.hasPermi('records:drugSale:list')")
    public TableDataInfo drugSaleList( DrugSale drugSale){
        String drugName = drugSale.getDrugName();
        Map<String, Object> params = drugSale.getParams();
        List<DrugSale> list = drugSaleService.selAllDrugSaleInfo(drugName, params);
        return getDataTable(list);
    }

    //根据药品名称和时间动态查询药品销售总量统计
    @RequestMapping("/sum")
    @PreAuthorize("@ss.hasPermi('records:drugSale:sum')")
    public TableDataInfo drugSaleSum(DrugSale drugSale){
        String drugName = drugSale.getDrugName();
        Map<String, Object> params = drugSale.getParams();
        List<DrugSale> drugSales = drugSaleService.selDrugSaleSum(drugName,params);
        return getDataTable(drugSales);

    }
}
